app: thread HeapAllocator through core module Init calls - #284
Conversation
cb02d98 to
a56cb25
Compare
| RetWithError<size_t> FSPlatform::GetDirSize(const String& dir) const | ||
| { | ||
| return fs::CalculateSize(dir); | ||
| return common::utils::CalculateSize(dir.CStr()); |
There was a problem hiding this comment.
[P1] Preserve directory sizes above INT_MAX
This switches production space accounting to common::utils::CalculateSize, whose std::accumulate starts with the literal 0, making the accumulator an int. Directories larger than INT_MAX therefore overflow before the result is converted to uintmax_t. Image and install directories can commonly exceed 2 GiB, so SpaceAllocator may receive a bogus size and make incorrect allocation or cleanup decisions. Please initialize the accumulator with uintmax_t {0} and also maybe good to add test on this case.
| @@ -0,0 +1,294 @@ | |||
| /* | |||
| * Copyright (C) 2024 Renesas Electronics Corporation. | |||
mykola-kobets-epam
left a comment
There was a problem hiding this comment.
Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>
| @@ -0,0 +1,108 @@ | |||
| /* | |||
| * Copyright (C) 2024 Renesas Electronics Corporation. | |||
mlohvynenko
left a comment
There was a problem hiding this comment.
Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
a178218 to
d4ab7a0
Compare
Aos core library APIs (crypto provider, PKCS11 manager, cert loader, cert handler, space allocators, image manager, launcher, monitoring, network manager, node config handler, etc.) now take an allocator as part of their redesigned Init signatures, so every app entry point (cm, iam, mp, sm) gains a HeapAllocator member and passes it through. Also refactors the IAM app to move its Init/Start/Stop logic out of App into a new AosCore class, matching the pattern already used by cm and sm, which keeps App as a thin Poco::Util::ServerApplication wrapper around AosCore. Updates the affected unit tests to construct a HeapAllocator and pass it to the library calls whose signatures changed, and fixes FSPlatform::GetDirSize to call the renamed common::utils::CalculateSize helper instead of the removed aos::fs::CalculateSize. Signed-off-by: Oleksandr Grytsov <al1img@gmail.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>
std::accumulate was seeded with an int literal 0, so the running
total was accumulated as int and only converted to uintmax_t on
return. Directories whose aggregate size exceeds INT_MAX (~2 GiB)
overflowed before conversion, which can make SpaceAllocator receive
a bogus size and make incorrect allocation or cleanup decisions.
Seed the accumulator with uintmax_t{0} instead, and add a regression
test that sums two sub-INT_MAX sparse files whose total crosses
INT_MAX.
Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com>
Reviewed-by: Mykola Kobets <mykola_kobets@epam.com>
Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>
The templateRecursion suppressions are no longer needed for these two make_unique<Alerts> calls. Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Mykhailo Lohvynenko <mykhailo_lohvynenko@epam.com> Reviewed-by: Mykola Kobets <mykola_kobets@epam.com> Reviewed-by: Mykola Solianko <mykola_solianko@epam.com>
d4ab7a0 to
cb44988
Compare
|




Aos core library APIs (crypto provider, PKCS11 manager, cert loader, cert handler, space allocators, image manager, launcher, monitoring, network manager, node config handler, etc.) now take an allocator as part of their redesigned Init signatures, so every app entry point (cm, iam, mp, sm) gains a HeapAllocator member and passes it through.
Also refactors the IAM app to move its Init/Start/Stop logic out of App into a new AosCore class, matching the pattern already used by cm and sm, which keeps App as a thin Poco::Util::ServerApplication wrapper around AosCore.
Updates the affected unit tests to construct a HeapAllocator and pass it to the library calls whose signatures changed, and fixes FSPlatform::GetDirSize to call the renamed common::utils::CalculateSize helper instead of the removed aos::fs::CalculateSize.